﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace DungeonGenerator
{
    public class JavaRandomizer:IRandomize
    {
        //the old seed from the RNG is saved in this one
        private long oldseed = 0;

        //The RNG. the seed is based on seconds from the "java epoch" ( I think..)
        //perhaps it's the same date as the unix epoch
        private int getRand(int min, int max)
        {
            //the seed is based on current date and the old, already used seed
            var now = DateTime.Now;
            long seed = now.Ticks + oldseed;
            oldseed = seed;

            var randomizer = new Random((int)seed);
            int n = max - min + 1;
            int i = randomizer.Next(n);
            if (i < 0)
                i = -i;
            //Console.WriteLine("seed: " + seed + "\tnum:  " + (min + i));
            return min + i;
        }

        #region IRandomize Members

        public bool NextBool()
        {
            throw new NotImplementedException();
        }

        public int Next(int bound1, int bound2)
        {
            return this.getRand(bound1, bound2);
        }

        public int NextSign()
        {
            throw new NotImplementedException();
        }

        #endregion
    }
}
